import json
from sdk.client import Client
from sdk.common import BuildClient

class Renew:
    def __init__(self, client):
        self.client = client

    def get_company_expire_device_list(self, req):
        get_params = {
            "page": req.page_model.page,
            "limit": req.page_model.limit
        }
        self.app_id = self.client.app_id
        self.app_secret = self.client.app_secret
        get_params = BuildClient.build_get_param(self,get_params)
        return self.client.get("/open/renew/getCompanyExpireDeviceList", get_params)

    def create_company_renew_order(self, req):
        self.app_id = self.client.app_id
        self.app_secret = self.client.app_secret
        post_params = BuildClient.build_post_param(self,req.__dict__) 
        return self.client.post("/open/renew/createCompanyRenewOrder", post_params)

    def get_company_renew_status(self, req):
        get_params = {"out_trade_no": req.out_trade_no}
        self.app_id = self.client.app_id
        self.app_secret = self.client.app_secret
        get_params = BuildClient.build_get_param(self,get_params)
        return self.client.get("/open/renew/getCompanyRenewStatus", get_params)
       
